package com.common;

import com.okcoin.websocket.client.StartWebcocket1;
import com.okok.controller.ProfileController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import static java.lang.Thread.sleep;

public class GreyStartServlet extends HttpServlet {
    private static Logger logger = LoggerFactory.getLogger(ProfileController.class);
    // Servlet的init方法会在Tomcat启动的时候执行
    @Override
    public void init() throws ServletException {
        // 需要实现的功能
        logger.info("开始自执行");
        MyThread read = new MyThread();
        // 使用另一个线程来执行该方法，会避免占用Tomcat的启动时间
        new Thread(read).start();
    }
    class MyThread implements Runnable {
        // Tomcat启动结束后执行
        @Override
        public void run() {
            // 子线程需要做的事情
            /*
            StartWebcocket1 startWebcocket1 = new StartWebcocket1();
            startWebcocket1.startWebcocket1();
            */
        }
    }
}